package cn.xshi.file.service.impl;

import cn.xshi.common.base.BaseService;
import cn.xshi.common.util.ExceptionUtil;
import cn.xshi.file.dao.AttachmentDao;
import cn.xshi.file.form.AttachmentForm;
import cn.xshi.file.model.Attachment;
import cn.xshi.file.service.AttachmentService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
 * @Desc 附件管理
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Service
public class AttachmentServiceImpl extends BaseService implements AttachmentService {

	@Resource
	private AttachmentDao attachmentDao;

	/**
	 * 分页
	 * @param attachmentForm
	 * @return
	 */
	public List<Attachment> getAttachmentListByCondition(AttachmentForm attachmentForm){
		try {
			return attachmentDao.getAttachmentListByCondition(attachmentForm);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 查询对象
	* @param id
	* @return
	*/
	public Attachment getAttachmentById(String id){
		try {
			return attachmentDao.getAttachmentById(id);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	* 添加
	* @param attachment
	* @return
	*/
	public int addAttachment(Attachment attachment){
		int i = 0;
		try {
			i = attachmentDao.addAttachment(attachment);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	 * 添加
	 * @param attachmentList
	 * @return
	 */
	public int addBatchAttachment(List<Attachment> attachmentList){
		int i = 0;
		try {
			i = attachmentDao.addBatchAttachment(attachmentList);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 修改
	* @param attachment
	* @return
	*/
	public int updateAttachment(Attachment attachment){
		int i = 0;
		try {
			i = attachmentDao.updateAttachment(attachment);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	* 删除
	* @param condition 
	* @return
	*/
	public int delAttachment(Map<String,Object> condition){
		int i = 0;
		try {
			i = attachmentDao.delAttachment(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	 * 根据如编号数组批量查询集合
	 * @param condition
	 * @return
	 */
	public List<Attachment> getAttachmentList(Map<String,Object> condition){
		try {
			return attachmentDao.getAttachmentList(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}
}
